﻿using MoetutuServer.Helper;
using MoetutuServer.Helper.PublishHelper;
using MoetutuServer.PublishHelper;
using MoetutuServer.RepairHelper;
using MoetutuServer.WebSite.Konachan;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml;

namespace MoetutuServer
{
    public partial class Form1 : Form
    {


        public Form1()
        {
            InitializeComponent();
            InitData();
        }

        private void InitData()
        {
            Helper.ViewHelper.GetGroupBox.RepairView(groupBox1);
            timer1.Enabled = FileHelper.FileExits(StaticValue.BinPath + "server.flag");//服务器启动
      
            FileHelper.FloderExits(StaticValue.BinPath, true);
            FileHelper.FloderExits(StaticValue.TempPath, true);
            FileHelper.FloderExits(StaticValue.ImgTemp1, true);
            FileHelper.DeleteAllChildrenFile(StaticValue.ImgTemp1);
            try
            {
                comboBox1.Items.AddRange(FileHelper.GetFileName(StaticValue.UserInfoPath).ToArray());
                if (FileHelper.FileExits(StaticValue.BinPath + "server.flag"))
                    comboBox1.SelectedIndex = 1;
                else
                    comboBox1.SelectedIndex = 1;
            }
            catch (Exception ex) {

                PrintLog.Log(ex);
            }
            //   Helper.ViewHelper.GetGroupBox.KonachanHelper(groupBox1);

            Helper.Currency.OperationLog.Scanner(StaticValue.OldImgIdPath);
            Helper.Currency.OperationLog.Scanner(StaticValue.PrintLogPath);
            StaticValue.PostUser = StaticValue.UserInfoPath + comboBox1.Text;
        }

        private void button1_Click(object sender, EventArgs e)
        {
          

        }

        private void button4_Click(object sender, EventArgs e)
        {
            System.Diagnostics.Process.Start(".\\");
        }

        private void button3_Click(object sender, EventArgs e)
        {

        }

        private void button2_Click(object sender, EventArgs e)
        {
        Helper.ViewHelper.GetGroupBox.    PixivScanner(groupBox1);
        }

        private void button3_Click_1(object sender, EventArgs e)
        {
            Helper.ViewHelper.GetGroupBox.KonachanHelper(groupBox1);
        }

        private void button5_Click(object sender, EventArgs e)
        {
            Helper.ViewHelper.GetGroupBox.RepairView(groupBox1);
           
        }





        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            StaticValue.PostUser = StaticValue.UserInfoPath + comboBox1.Text;
            Console.WriteLine(StaticValue.PostUser);
        }

        private void button6_Click(object sender, EventArgs e)
        {


            // 
        }

        private void button7_Click(object sender, EventArgs e)
        {

            /*
            List<string> AllImg = HtmlHelper.GetLinkVlaueList(PublishHelper.ModifyContent.GetContent(StaticValue.UserInfoPath + comboBox1.Text, Convert.ToInt32(textBox1.Text)), "//div[@class='Original_img']/a");
            foreach (string lin in AllImg) {


                Console.WriteLine(lin);
            }*/
        }

        private void button6_Click_1(object sender, EventArgs e)
        {
            Helper.ViewHelper.GetGroupBox.CorrenyHelper(groupBox1);
        }

        private void button7_Click_1(object sender, EventArgs e)
        {
            Helper.ViewHelper.GetGroupBox.PixivHelper(groupBox1);
        }

        private void button8_Click(object sender, EventArgs e)
        {
            WebSite.Huaban.HuabanScanner.Start();
        }

        private void button1_Click_1(object sender, EventArgs e)
        {
            TimerStart();

        }

        private static void TimerStart()
        {
            FileHelper.AppendUTF8Text(StaticValue.OldImgIdPath, "本次启动时间"+DateTime.Now.ToString());
            //   WebSite.Pixiv.Scanner.Start();
            WebSite.Huaban.HuabanScanner.Start();
            ScannerKonachan.Start();


            StartScanner.AnalysisContent(StaticValue.PostUser, 1, 5);
        }
        int TimeCount = 0;
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (TimeCount < 10)
            {
                label1.Text = string.Format("距离启动{0}秒",10- TimeCount++);
            }
            else
            {
                TimerStart();
                label1.Text = "已启动";
                timer1.Enabled = false;
            }

        }

        private void button9_Click(object sender, EventArgs e)
        {
            timer1.Enabled = false;
        }

        private void button10_Click(object sender, EventArgs e)
        {
            Console.WriteLine(WebSite.PicServer.TagUpdate.UpdateforRoma.InitSearchForOldTag("舰队收藏/舰娘/舰队collection-------tail"));
        //    Console.WriteLine(WebSite.PicServer.TagUpdate.TagUpdateHelper.InitSearchForOldTag("细带三角裤-------string_panties"));
        }
    }
}
